<?php
include ("dbconnect.php");
/* if (isset($_POST['cp']) || isset($_POST['name'])) {
    header("Location: index.php");
} */
$setname = mysql_real_escape_string($_POST['name']);
$setcp = mysql_real_escape_string($_POST['cp']);
$search_sql = "SELECT name FROM bar WHERE name LIKE '%$setname%' AND cp LIKE '%$setcp%'";
$search_query = mysql_query($search_sql) or die('Erreur SQL !<br />'.$search_sql.'<br />'.mysql_error());;
if (($setcp || $setname) && (mysql_num_rows($search_query) != 0)) {
    $search_rs = mysql_fetch_assoc($search_query);
}
?>
<!DOCTYPE html>
<html>
<p>Les bars que tu cherches :</p>
<?php
if (($setcp || $setname) && (mysql_num_rows($search_query) != 0)) {
    do {
        echo '<a href="barpage.php?barname='.$search_rs['name'].'"> '.$search_rs['name'].'</a><br />';
    } while ($search_rs = mysql_fetch_assoc($search_query));
} else {
    echo "Aucun résultat";
}
?>
</html>